#ifndef VAR_DEF_H
#define VAR_DEF_H
#include <QFile>
#include <QTextStream>
#include <QObject>
#include <QListView>
#include<QList>

#include <gsl/gsl_math.h>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_spline.h>

#include "math.h"

#include <QtGui/QDialog>
#include "ui_symphonie.h"
#include <QFileDialog>
#include<QStandardItem>
#include <qwaitcondition.h>
#include <QDebug>

//#include <QSqlTableModel>
#include <QMenu>
#include <QDirModel>
#include <QPalette>
#include <QColorGroup>
#include <QDesktopWidget>
#include <QStyleFactory>
#include<QLabel>
#include<QItemSelectionModel>
#include<QString>
#include<QProgressBar>
#include<QSignalMapper>

//#include "deform.h"


#include "Plot2D.h"
#include "Plot3D.h"
#include "treemodel.h"
#include "treeitem.h"
#define one gsl_complex_rect(1.0,0.0)


#include <qwt_plot.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_curve.h>
#include <qwt_legend.h>
#include <qwt_data.h>
#include <qwt_text.h>
#include <qwt_math.h>


qreal myMin(QVector<qreal> x)
{
    qreal min = x.at(0);
    for(int i=0;i<x.count();i++)
        if(x.at(i)<min) min = x.at(i);
    return min;
}

qreal myMax(QVector<qreal> x)
{
    qreal max = x.at(0);
    for(int i=0;i<x.count();i++)
        if(x.at(i)>max) max = x.at(i);
    return max;
}



class SPl_ui{
        public:
    QList<QString> Optim_paramlist,Optim_paramlist2;
    QString Optim_Computed_on,Optim_target;
};

class MainConfig{
public:
    QString Current_WorkSpace;
    SPl_ui SPL;

private:

};

class Variables_struc{
public:
    QString Label;
    QString Units;
    int var;
        private:
};

class Freq_and_Vars{
public:
    QList< Variables_struc> freqvar;
    float freq;
        private:
};

class Single_gamma_cmplx{
public:
    QString Label;
    gsl_complex val;
        private:

};

class List_gamma_cmplx{
public:
    QList<Single_gamma_cmplx> List_Gamma;
    QList<Single_gamma_cmplx> List_Gamma_polar;
    QList<Single_gamma_cmplx> List_Impedance;
    int convert_gamma_2_impedance();
    int convert_gamma_2_polar();

        private:

};
class swp_rec{
public:
    QString Label;
    QList<float> swp;
    float min, max;
    int IsEmpty;
    void compute_min_max();
        private:
};
class LP_rec{
public:
    QString Label;
    int valid;
    float G_x, G_y;
    QList<swp_rec*> LP;
    QList<List_gamma_cmplx> gammas;
    int Add_compression_infos();

    int compute_AMPM();
        private:
};

class spl_rec{
public:
    QString Label;
    float Freq;
    int valid;
    QList<LP_rec*> spl;
        private:
};

typedef QList<QStringList> QListQstringQList;


class record_def{
public:
    record_def();
    ~record_def();
    QString filetype;
    QString Sweep_Type;
    QString filename;
    QString Label;
    QString Date;
    QString Shortfilename;
    int nbVariables;
    int nbFreq;
    QList<Freq_and_Vars> FreqVariables;
    QStringList Headers_list;
    QList<spl_rec*> All_Freq_data;

    int debug;
    TreeModel *model;
   int FillTreemodel();

private:
};

class Dataset{
public:
    int active_dataset;
    int active_freq;
    int active_load;
    QList<record_def*> record;
    record_def record_optimums;
    LP_rec Single_load_Max;
 };


#endif // VAR_DEF_H
